package offer.diff;

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author DengYuan2
 * @create 2021-03-20 19:00
 */
public class n_60 {
    public static void main(String[] args) {
        n_60 n = new n_60();
        List<Map.Entry<Integer, Double>> res = n.dicesSum(2);
        System.out.println(res);
    }

    /**
     *
     * @param n
     * @return
     */
    public List<Map.Entry<Integer, Double>> dicesSum(int n) {
        final int face = 6;
        final int pointNum = face * n;
        long[][] dp = new long[n + 1][pointNum + 1];
        for (int i = 1; i <= face; i++) {
            dp[1][i] = 1;
        }
        ArrayList<Map.Entry<Integer, Double>> ret = new ArrayList<>();
        for (int i = 2; i <= n; i++) {
            for (int j = i; j <= pointNum; j++) {
                for (int k = 1; k <= face && k <= j; k++) {
                    dp[i][j] += dp[i - 1][j - k] ;
                }

            }

        }
        double total = Math.pow(face,n);
        for (int i = n; i <=pointNum; i++) {
            AbstractMap.SimpleEntry<Integer, Double> entry = new AbstractMap.SimpleEntry<>(i, dp[n][i] / total);
            ret.add(entry);
        }
        return ret;
    }
}
